package cn.tang.tframe.common.exception;

import cn.tang.tframe.common.base.BaseResult;
import cn.tang.tframe.common.base.ResultCode;
import cn.tang.tframe.common.utils.lang.StringUtils;


/**
 * @author huaicheng.thc Date: 2015-11-05 17:18:04
 */
public class ExceptionUtil {


	public static BaseResult baseCustomeRtmExceptionToBaseResult(BaseRtmException excep) {
		if (null != excep) {
			String message = excep.getMessage();
			return BaseResult.fail(StringUtils.isNotBlank(message) ? message : "服务调用错误");
		}
		return null;
	}


	public static BaseException convertRtmExceptionToExeption(BaseRtmException throwable) {
		if (null == throwable) {
			return null;
		}
		return new BaseException(throwable.getErrorCode() == null ? ResultCode.OTHER.getCode()
				: throwable.getErrorCode(), throwable.getMessage());
	}

}
